Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiled Gallery: Add noResize to block save #29496

Merged
merged 1 commit into from
Dec 17, 2018

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Dec 17, 2018

The block save method should not depend on the browser. It should not
create ResizeObservers and should be completely deterministic.

This helps ensure that the block can be saved and parsed consistently so
that it is not invalidated by the parser.

Bite sized PR from #29465

Testing

  1. Add a tiled gallery block and play with it.
  2. Resize your browser window.
  3. Switch between visual and code editor
  4. Save draft
  5. Refresh editor
  6. The block should be valid (previously, this would often be invalid)
  7. Repeat previous steps.

The block save method should not depend on the browser. It should not
create ResizeObservers and should be completely deterministic.

This helps ensure that the block can be saved and parsed consistently so
that it is not invalidated by the parser.
@sirreal sirreal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Goal] Gutenberg Working towards full integration with Gutenberg [Block] Tiled Gallery labels Dec 17, 2018
@sirreal sirreal self-assigned this Dec 17, 2018
@matticbot
Copy link
Contributor

@sirreal sirreal requested a review from simison December 17, 2018 13:18
@sirreal
Copy link
Member Author

sirreal commented Dec 17, 2018

I'm not in love with noResize, but it works for now.

Ideally, we'd like to separate out structural layout (React rendering) from any resizing logic necessary in JavaScript.

if ( width && width !== this.state.width ) {
this.setWidth( width );
handleResize = this.props.noResize
? () => {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that this ternary is just an optimization because we already have if ( ! this.props.noResize ) in componentDidMount ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, it's redundant as you note. I expect we may start to call resize on mount to get initial sizes set up. This is also complete, noResize really will not resize.

Copy link
Member

@simison simison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests well 👍

A good step towards possibly removing style attributes from saved HTML.

@sirreal sirreal added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 17, 2018
@sirreal sirreal merged commit d9eac51 into master Dec 17, 2018
@sirreal sirreal deleted the update/g7g-tg-noresize-on-save branch December 17, 2018 14:26
blowery added a commit that referenced this pull request Dec 18, 2018
…sh-2019

* origin/master:
  change "expert" to "support" in page route and title (#29459)
  Add note to concierge upsell page about sessions only being offered in English. (#29461)
  Jetpack Blocks: Fix webpack warnings due to dynamic import (#29509)
  Gutenberg: Reset core resolvers on site change (#29445)
  Signup: Remove Masterbar from Signup (#28886)
  Fix missing bumpStat call (#29504)
  Gutenberg Jetpack Preset: Generate imports dynamically from index.json (#29435)
  Fix the clean:public script to do a better job cleaning public/ folder (#29354)
  Tiled gallery: Add alignWide support (#29493)
  Tiled Gallery: Add noResize to block save (#29496)
  Show G Suite user fields by default (#29458)
  ColorThemes: Add GA and bumpStat events for scheme picking (#29413)
  Remove legacy mock for extensions reducer (#29397)
  Antispam promo card: tweak copy to make it clearer (#29440)
  prevent 0 as street number for ebanx checkouts (#29487)
  Gutenberg: Update Related Posts to use the posts endpoint (#29439)
  remove override on payment methods name in India (#29406)
  Add a space to separate "the" from the holiday name placeholder. (#29479)
  Revert "Migrate my-sites/sharing to webpack css pipeline (#28607)" (#29463)
  Gutenpack Subscription Block (Take two) (#28887)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Tiled Gallery [Goal] Gutenberg Working towards full integration with Gutenberg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants